FIND_PACKAGE(PXAR REQUIRED)

GET_FILENAME_COMPONENT(DIRNAME ${CMAKE_CURRENT_LIST_DIR} NAME)
SET(PLUGIN_NAME plugin.${DIRNAME})
SET_PROPERTY(GLOBAL APPEND PROPERTY CONVERTER_PLUGIN ${PLUGIN_NAME})

INCLUDE_DIRECTORIES(include)

SET(PLUGIN_SRC
  src/CMSPixelDUTConverterPlugin.cc
  src/CMSPixelQUADConverterPlugin.cc
  src/CMSPixelTRPConverterPlugin.cc
  src/CMSPixelConverterPlugin.cc
  src/CMSPixelREFConverterPlugin.cc
  )
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${PLUGIN_SRC})
INSTALL(TARGETS ${PLUGIN_NAME}
  RUNTIME DESTINATION bin
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
  )



SET(name "CMSPixelProducer")

IF(PXARCORE_FOUND)
ELSE(PXARCORE_FOUND)
  MESSAGE(FATAL_ERROR "Could not find CMSPixel pxarCore! Make sure to set the environment variable $PXARPATH to the path of your pxar installation!")
ENDIF(PXARCORE_FOUND)

SET(sourcefiles src/CMSPixelProducer.cxx src/CMSPixelConfigParser.cxx)

INCLUDE_DIRECTORIES(include ${PXARCORE_INCLUDE_DIRS})
ADD_EXECUTABLE(${name} ${sourcefiles})

TARGET_LINK_LIBRARIES(${name} EUDAQ ${EUDAQ_THREADS_LIB} ${PXARCORE_LIBRARIES})

INSTALL(TARGETS ${name}
  RUNTIME DESTINATION bin
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib)

